package com.injurydetection.www.control;

import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

import com.injurydetection.www.R;

/**
 * Created by sunguiyong on 2020/8/12
 */
public class ExamineControl {
    /**
     * 血型选择
     */
    public static void bloodChange(Context context, TextView textView) {
        textView.setTextColor(context.getResources().getColor(R.color.bloodselect));
        textView.setBackgroundColor(context.getResources().getColor(R.color.blood_select_bg));
    }

    /**
     * 血型未选择
     *
     * @param context
     * @param textView
     */
    public static void bloodChangeNo(Context context, TextView textView) {
        textView.setTextColor(context.getResources().getColor(R.color.blood_no_select));
        textView.setBackgroundColor(context.getResources().getColor(R.color.blood_no_select_bg));
    }

    /**
     * 设置textview的点击渐变色
     *
     * @param views
     */
    public static void setAlphaChange(final View... views) {
        for (View view : views) {
            view.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    switch (event.getAction()) {
                        case MotionEvent.ACTION_DOWN:
                            v.setAlpha(0.5f);
                            break;
                        case MotionEvent.ACTION_UP:
                        case MotionEvent.ACTION_CANCEL:
                            v.setAlpha(1.0f);
                            break;
                    }
                    return false;
                }
            });
        }
    }
}
